import 'package:flutter/material.dart';
import 'package:flutter_admin/api/odoo/udt_tb_workreportrecord_odoo_api.dart';
import 'package:flutter_admin/pages/common/cry/model/response_body_api.dart';
import 'package:flutter_admin/pages/large_screen/production_schedule/day_detail.dart';
import 'package:flutter_admin/pages/large_screen/production_schedule/day_task.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'day_data.dart';

class ProductionSchedule extends StatefulWidget {

  ProductionSchedule({Key? key}):super(key: key);

  _ProductionScheduleState createState() => _ProductionScheduleState();
}

class _ProductionScheduleState extends State<ProductionSchedule>{

  List stationList = [];

  List processList = [];

  Map workshop = {};

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _loadData();
  }

  _loadData() async{
    ResponseBodyApi res = await UdtTbWorkreportrecordOdooApi.plantProductionStation();
    if(res.success!){
      stationList = res.data[0]["station"];
      processList = res.data[0]["process"];
      workshop = res.data[0]["workshop"];
      setState(() {});
    }
  }


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      alignment: Alignment.center,
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage("assets/bg/bg6.jpg"),
          fit: BoxFit.cover,
        ),
      ),
      child: Column(
        children: [
          Padding(
            padding: EdgeInsets.all(10.r),
            child: Text("生产进度跟踪与监视",style: TextStyle(
                fontSize: 36.sp,
                decoration: TextDecoration.none,
                color: Color.fromRGBO(255, 255, 255, 1)
            ),),
          ),
          Expanded(child: DayTask(stationList: stationList,)),
          Expanded(child: DayData(processList: processList,)),
          Expanded(child: Row(
            children: [
              workshop["Planned_quantity_today"]!=null ? Expanded(child: DayDetal(title: "今日计划数量",context: workshop["Planned_quantity_today"].toString(),)):Container(),
              workshop["Quantity_completed_today"]!=null ? Expanded(child: DayDetal(title: "今日报工数量",context: workshop["Quantity_completed_today"].toString(),)):Container(),
              workshop["Plate_Making_Thickness"]!=null ? Expanded(child: DayDetal(title: "今日上岗人数",context: workshop["Plate_Making_Thickness"].toString(),)):Container(),
              workshop["Percentage_Complete"]!=null ? Expanded(child: DayDetal(title: "今日达成率",context: (workshop["Percentage_Complete"]*100).toString()+"%",)):Container(),
            ],
          )),

        ],
      ),
    );
  }
}